package com.rk.kbk.controller;

import com.rk.kbk.dao.OrderDao;
import com.rk.kbk.model.Order;
import com.rk.kbk.model.User;
import com.rk.kbk.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by bilibili on 2017/3/9.
 */
@CrossOrigin
@RestController
@Transactional
public class PubllicMethods{
    @Autowired
    private UserService userService;
    @Autowired
    private OrderDao orderDao;

        public boolean checkCurrentLogin(Long id){
            boolean flag=false;
            Long loginUserId = userService.currentUserId();//获取当前登录着
            Order order=orderDao.findOne(id);
            User user=order.getShop();
            if( loginUserId!=null  && user.getId().equals(loginUserId)){
                flag=true;
            }
            return flag;
        }


}
